#include <iostream>
using namespace std;

class Parent{
public:
    Parent(){
        cout << "Parent construct function"  << endl;
    };
    ~Parent(){
    // virtual ~Parent(){
        cout << "Parent destructor function" <<endl;
    }
};

class Son : public Parent{
public:
    Son(){
        cout << "Son construct function"  << endl;
    };
    ~Son(){
        cout << "Son destructor function" <<endl;
    }
};

class A {
    void f(){}
    static void f1(){}
    static int a;
};
class B
{
public:
    virtual void f(){}
};
class B1 :public virtual  B{};
class B2 :public virtual  B{};
class D : public B1, public B2
{
public:
    virtual void f(){}
};
class D1 : public B{};
class D2 : public B
{
public:
    virtual void f(){}
};
class D3 : public virtual A {};
class D4 : public virtual A
{
public:
    virtual void f(){}
    virtual void f2(){}
};

int main()
{
    Parent* p = new Son();
    delete p;
    p = NULL;

    A a;
    B b;
    B1 b1;
    B2 b2;
    D d;
    D1 d1;
    D2 d2;
    D3 d3;
    D4 d4;
    cout << "sizeof(a)=" << sizeof(a)<<endl;
    cout << "sizeof(b)=" << sizeof(b)<<endl;
    cout << "sizeof(b1)=" << sizeof(b1) << endl;
    cout << "sizeof(b2)=" << sizeof(b2) << endl;
    cout << "sizeof(d)=" << sizeof(d) << endl;
    cout << "sizeof(d1)=" << sizeof(d1) << endl;
    cout << "sizeof(d2)=" << sizeof(d2) << endl;
    cout << "sizeof(d3)=" << sizeof(d3) << endl;
    cout << "sizeof(d4)=" << sizeof(d4) << endl;
    return 0;
}
//运行结果：
//Parent construct function
//Son construct function
//Son destructor function
//Parent destructor function
